<% content_for :page_title do %>
  <%= t(:listing_banner_boxes) %>
<% end %>

<% content_for :page_actions do %>
  <div class="toolbar" data-hook="toolbar">
    <ul class="actions header-action-links inline-menu">
      <li id="new_banner_box_link">
        <%= button_link_to t(:new_banner_box), new_object_url, { :remote => true, :icon => 'icon-plus', :id => 'admin_new_banner_box' } %>
      </li>
    </ul>
  </div>
<% end %>

<%= render :partial => 'spree/admin/shared/banner_box_sub_menu' %>

<% content_for :table_filter_title do %>
  <%= Spree.t(:search) %>
<% end %>

<% content_for :table_filter do %>
  <div data-hook="admin_banner_sidebar">

    <%= search_form_for [:admin, @search] do |f| %>
        <%- locals = {:f => f} %>
        <div data-hook="admin_banner_index_search">
          <div class="alpha four columns">
            <div class="field">
              <%= f.label :category_eq, Spree.t(:category) %>
              <%= f.select :category_eq, Spree::BannerBox.categories_for_select, {:include_blank => true}, {:class => 'select2 fullwidth'} %>
            </div>
          </div>
          <div class="eight columns">
            <div class="field">
              <%= f.label :url_cont, Spree.t(:url) %>
              <%= f.text_field :url_cont, :size => 15 %>
            </div>
          </div>
          <div class="three columns omega">
            <div class="field checkbox">
              <label>
                <%= f.check_box :enabled_true %>
                <%= Spree.t(:show_only_enabled) %>
              </label>
            </div>
        </div>

        <div class="clear"></div>

        <div class="form-buttons actions filter-actions" data-hook="admin_banner_index_search_buttons">
          <%= button Spree.t(:search), 'icon-search' %>
        </div>
    <% end %>
  </div>
<% end %>


<div id="new_banner_box" data-hook></div>

<% if @collection.any? %>
<table class="index sortable" id="listing_banner_boxes" data-sortable-link="<%= update_positions_admin_banner_boxes_url() %>">
  <colgroup>
  <col style="width: 5%">
  <col style="width: 15%;">
  <col style="width: 10%;">
  <col style="width: 10%;">
  <col style="width: 17%;">
</colgroup>
<thead>
  <tr data-hook="admin_banner_index_headers">
    <th colspan="2"><%= t(:thumbnail) %></th>
    <th><%= t(:category) %></th>
    <th><%= t(:url) %></th>
    <th data-hook="admin_banner_index_header_actions" class="actions"></th>
  </tr>
</thead>
<tbody>
  <% @collection.each do |banner_box| %>
  <tr id="<%= spree_dom_id banner_box %>" data-hook="admin_banner_boxes_index_rows" class="<%= cycle('odd', 'even') %>">
    <td class="no-border">
      <span class="handle"></span>
    </td>
    <td class="align-center"><%= image_tag(banner_box.attachment(:mini)) %></td>
    <td class="align-center"><%= banner_box.category rescue '' %></td>
    <td class="align-center"><%= banner_box.url rescue '' %></td>
    <td class="actions" data-hook="admin_banner_index_row_actions">
      <%= link_to_edit banner_box, :no_text => true, :class => 'edit' %>
      &nbsp;
      <%= link_to_with_icon 'icon-copy', t(:clone), clone_admin_banner_box_url(banner_box), :no_text => true, :class => 'clone' %>
            &nbsp;
      <%= link_to_delete banner_box, :no_text => true %>
    </td>
  </tr>
  <% end %>
</tbody>
</table>
<% else %>
<div class="no-objects-found">
  <%= t(:no_results) %>
</div>
<% end %>

<%= paginate @collection %>
